new Vue({
  el: '#app',
  data() {
    return {
      form: {
        // Article_Name: "",
        Type: "0",
        Group_Purchasing_SerialNumber: '',
        token: $.cookie("token"),
        Enterprise_Info_SerialNumber: $.cookie("enterprise"),
        page: 1,			//页数
        limit: 10,			//每页数据条数
      },
      total: 0,
      flag: true,
      category: [],
      Enterprise: [],
      tableData: [],

      loading: false,
      // Enterprise_Info_SerialNumber: $.cookie("enterprise")
    }
  },
  mounted() {
    //默认查询第一组数据
    this.getList(this.form)
    //查询所有类别
    // this.getCategoryData()
    //查询所有发布过采购的公司
    // this.getEnterpriseData()
  },
  methods: {
    //通过关键字查询数据
    onSerach() {
      this.getList(this.form)
    },
    // //通过选择类别查询数据
    // change(e) {
    //   this.form.Category_SerialNumber = e
    //   this.getList(this.form)
    // },
    // //通过选择公司查询数据
    // change1(e) {
    //   this.form.Enterprise_Info_SerialNumber = e
    //   this.getList(this.form)
    // },
    //号码按键查询
    handleSizeChange(val) {
      this.form.page = 1;
      this.form.limit = val;
      this.getList(this.form)
    },
    //号码按键查询
    handleCurrentChange(val) {
      this.form.page = val;
      this.getList(this.form)
    },
    //分页查询数据
    getList(data) {
      let _this = this
      $.ajax({
        type: 'POST',
        data,
        url: DomainName + '/getGroupTransactionAllAction',
        success: function (Result) {
          _this.tableData = Result.tableData;
          console.log(Result)
          _this.total = parseInt(Result.limit)
        },
        complete: function (XMLHttpRequest) {
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        dataType: "json"
      })
    },
    //  再次编辑
    goEditDetails(row) {
      sessionStorage.setItem("Group_Purchasing_SerialNumber", row.Group_Purchasing_SerialNumber)
      sessionStorage.setItem("Group_Transaction_SerialNumber", row.Group_Transaction_SerialNumber)
      window.location.href = './EditDetails.html'
      // window.location.href = './EditDetails.html'
    },
    // 详情
    goDetail(row) {
      sessionStorage.setItem("Group_Purchasing_SerialNumber", row.Group_Purchasing_SerialNumber)
      sessionStorage.setItem("Group_Transaction_SerialNumber", row.Group_Transaction_SerialNumber)
      window.location.href = './Detail.html'
    },
    // 确认合同
    ConfirmContract(row) {
      sessionStorage.setItem("Group_Purchasing_SerialNumber", row.Group_Purchasing_SerialNumber)
      sessionStorage.setItem("Group_Transaction_SerialNumber", row.Group_Transaction_SerialNumber)
      window.location.href = './ConfirmContract.html'
    },
    // 确认收货
    ConfirmReceipt(row) {
      console.log(row)
      let _this = this;
      _this.loading = true
      row.Row_Status = '6'
      $.ajax({
        type: 'POST',
        data: {
          Group_Transaction_SerialNumber: row.Group_Transaction_SerialNumber,
          token: $.cookie("token")
        },
        url: DomainName + '/GroupTransactionStateAction',
        success: function (Result) {
          console.log(Result)
          _this.getList(_this.form)
          _this.$message.success("收货成功");
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        dataType: "json"
      })

    }
  },
})

